package com.bb.blog.code.threading;

import java.util.concurrent.*;

public class Test {
    public static long i = 1;
    public static long y = 0;

    public static void main(String[] args) throws InterruptedException {
//        ArrayBlockingQueue<String> blockingQueue = new ArrayBlockingQueue<String>(1);
//        blockingQueue.put("123");
//        blockingQueue.put("123");
        CyclicBarrier cyclicBarrier= new CyclicBarrier(3, new Runnable() {
            @Override
            public void run() {
                System.out.println("嘿嘿");
            }
        });


        ExecutorService executorService = Executors.newCachedThreadPool();
//        executorService.execute(() -> System.out.println("asdasd"));
        for (int j = 0; j < 10; j++) {

            executorService.execute(() -> {
                try {
                    cyclicBarrier.await();
                } catch (BrokenBarrierException | InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("我过来了");
            });

        }
    }
}
